package com.etc.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.etc.entity.Travels;
import com.etc.service.TravelsService;

@Controller
@RequestMapping
public class HomePageController {

    @Resource
    private TravelsService ts;

    @RequestMapping(value = "home", method = RequestMethod.GET)
    public String toHomePage(ModelMap modelMap, HttpSession session) {
        List<Travels> list = ts.selectAll();
        session.setAttribute("Travels", list);
        // System.out.println(home);
        // 用于标记页面显示按钮高亮
        modelMap.put("flag", "home");
        return "home";
    }

    @RequestMapping(value = "area", method = RequestMethod.GET)
    public String toArea(ModelMap modelMap) {
        modelMap.put("flag", "area");
        return "area";
    }

    @RequestMapping(value = "route", method = RequestMethod.GET)
    public String toRoute(ModelMap modelMap) {
        modelMap.put("flag", "route");
        return "route";
    }

    @RequestMapping(value = "sharing", method = RequestMethod.GET)
    public String toSharing(ModelMap modelMap) {
        modelMap.put("flag", "sharing");
        return "sharing";
    }

    @RequestMapping(value = "carousel_1", method = RequestMethod.GET)
    public String toCarousel_1(ModelMap modelMap) {
        modelMap.put("flag", "carousel_1");
        return "carousel_1";
    }

    /*@RequestMapping(value = "scenics/{sid}", method = RequestMethod.GET)
    public String toScenicDetails(@ModelAttribute("sid") String keyword, ModelMap modelMap) {
        // 放入rquestScope
        modelMap.put("flag", "area");
        return "scenicDetails";
    }*/

    @GetMapping("recommend")
    public String toRecommend(ModelMap modelMap) {
        modelMap.put("flag", "area");
        return "recommend";
    }

}
